$(document).ready(function () {
    if (/locationHash=[^;]*/g.test(document.cookie)) {
        var hash = /locationHash=([^;]*)/g.exec(document.cookie)[1].split('_');
        location.hash = "#" + hash[0];
        if (hash.length == 2 && hash[1] > 0) {
            var $ll = $("#" + hash[0]);
            $ll.siblings(".tab").find("a").removeClass("active").eq(hash[1]).addClass("active");
            $ll.siblings(".detail").find(".con").removeClass("on").eq(hash[1]).addClass("on");
        }
        document.cookie = "locationHash=;expires=" + new Date().toGMTString();
    }
    $("#recentBrowse").hide();
    $('.drama-poster li').live("hover", function () {
        $('.show-poster-3-on').removeClass('show-poster-3-on');
        $(this).addClass('show-poster-3-on');
    });

    var categorymap = {};
    getNickName();
    initcityAdList();

    $('#changeartist').live("click", function () {
        var pageindex = parseInt($(this).attr("pageindex"));
        if (pageindex == parseInt($(this).attr("pagecount"))) {
            pageindex = 0;
        }
        var data = artistmap[pageindex];
        if (data == null) {
            return;
        }
        pageindex = pageindex + 1;
        $(this).attr("pageindex", pageindex);
        $("#artistlist").html(bindArtistList(data));
    });
    $('#changevenue').live("click", function () {
        var pageindex = parseInt($(this).attr("pageindex"));
        if (pageindex == parseInt($(this).attr("pagecount"))) {
            pageindex = 0;
        }
        var data = venuemap[pageindex];
        if (data == null) {
            return;
        }
        pageindex = pageindex + 1;
        $(this).attr("pageindex", pageindex);

       
        $("#veunelist").html(bindArtistList(data));
    });

  
});
(function ($) {
    String.format = function () {
        if (arguments.length == 0)
            return null;

        var str = arguments[0];
        for (var i = 1; i < arguments.length; i++) {
            var re = new RegExp('\\{' + (i - 1) + '(:(\\d+))?\\}', 'gm');
            var rs = re.exec(str);
            if (typeof rs != "undefined" && rs != null) {
                var v = arguments[i];
                if (typeof rs[2] != "undefined") {
                    var l = (v + "").length;
                    if (l < (rs[2] - 0)) {
                        v = ("000000000000".substr(0, rs[2] - l)) + v;
                    }
                }
                str = str.replace(re, v);
            }
        }
        return str;
    };

    String.prototype.format = function () {
        if (arguments.length == 0)
            return null;

        var str = this;
        for (var i = 0; i < arguments.length; i++) {
            var re = new RegExp('\\{' + (i) + '\\}', 'gm');
            str = str.replace(re, arguments[i]);
        }
        return str;
    };
    String.prototype.trim = function () {
        return this.replace(/(^\s*)|(\s*$)/g, "");
    };
    String.prototype.template = function (obj) {
        return this.replace(/\{([a-z_]+)\}/gi, function (m, s) { return obj[s] || ""; });
    };
    String.prototype.getPart = function (s, e) {
        var re = new RegExp(s + "[\\w\\W]*" + e, "gi");
        return this.match(re);
    };
    String.prototype.subString = function (length) {
        var l = 0;
        for (var i = 0; i < this.length; i++) {
            var tt = escape(this[i]);
            if (tt.indexOf("%u") == 0) {
                l += 2;
            } else {
                l += 1;
            }
            if (l > length) {
                var txt = this.substring(0, i) + "...";
                return txt;
            }
        }
        return this + "";
    };

    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds()
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };
    Date.parseJsonDate = function (jsonDate) {
        //		if(jsonDate == null) { return null; }
        if (Object.prototype.toString.call(jsonDate) == "[object Date]") {
            return jsonDate;
        }
        var reg = /\((\d+)\)/;
        if (reg.test(jsonDate))
            return new Date(reg.exec(jsonDate)[1] - 0);
        return utlis.servertime();
    };
    (function () {
        if (typeof (Array.join) != "function") {
            Array.join = function (arr, s) {
                if (Object.prototype.toString.call(arr) == "[object Array]") {
                    return arr.join(s);
                }
                return "";
            }
        }
    })();
})(jQuery);



//推荐城市广告轮播图加载
function initcityAdList() {


    $("#topadtitle li.itm span.txt").each(function () {
        var $this = $(this), txt = $this.text();
        $this.text(txt.subString(22));
    });
    try {
        dm_slide.render();
        dm_slide.bind();
        dm_slide.auto();
    } catch (e) { }
}


function getNickName() {
    var strHtml = "";
    var userinfo = dui.$('#headerUserinfo');
    userinfo.innerHTML = strHtml;
}
//读取cookies
function getCookieValue(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return decodeURI(arr[2]);
    else
        return null;
}